package com.licq.ldoc.domain.support;

import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateToStringBehavior extends ToStringBehavior {

	@Override
	public String doToString(Object obj) {
		Date date = (Date) obj;
		SimpleDateFormat format = null;
		if (java.sql.Date.class.isInstance(obj)) {
			format = new SimpleDateFormat("yyyy-MM-dd");
		} else if (Time.class.isInstance(obj)) {
			format = new SimpleDateFormat("HH:mm:ss");
		} else {
			format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		}
		return format.format(date);
	}

}
